package csc.fresher.finalgroupfour.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class Transaction implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long transactionId;
	
	@ManyToOne
	@JoinColumn(name="sourceAccount")
	private Account sourceAccount;
	
	@ManyToOne
	@JoinColumn(name="targetAccount")
	private Account targetAccount;
	
	private long amount;
	
	@ManyToOne
	@JoinColumn(name="transactionState")
	private State transactionState;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date beginDate;
	@Temporal(TemporalType.TIMESTAMP)
	private Date endDate;
	
	public Transaction() {}
	
	public Transaction(Account sourceAccount, Account targetAccount,
			long amount, Date beginDate, Date endDate, State transactionState) {
		this.sourceAccount = sourceAccount;
		this.targetAccount = targetAccount;
		this.amount = amount;
		this.beginDate = beginDate;
		this.endDate = endDate;
		this.transactionState = transactionState;
	}

	public Long getTransactionId() {
		return transactionId;
	}

	public void setTransactionId(Long transactionId) {
		this.transactionId = transactionId;
	}
	
	public Account getSourceAccount() {
		return sourceAccount;
	}

	public void setSourceAccount(Account sourceAccount) {
		this.sourceAccount = sourceAccount;
	}

	public Account getTargetAccount() {
		return targetAccount;
	}

	public void setTargetAccount(Account targetAccount) {
		this.targetAccount = targetAccount;
	}

	public long getAmount() {
		return amount;
	}

	public void setAmount(long amount) {
		this.amount = amount;
	}

	public State getTransactionState() {
		return transactionState;
	}

	public void setTransactionState(State transactionState) {
		this.transactionState = transactionState;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
}
